var a = getApp();

Page({
    data: {
        isAsc: !0,
        voiceList: [],
        display_order: "",
        total: 0,
        isLoadMore: !0,
        page: 1,
        total_page: 0
    },
    onLoad: function(a) {
        this.getData();
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        if (!(this.data.page >= this.data.total_page)) {
            var a = this.data.page + 1;
            this.data.page = a, this.getMoreData();
        }
    },
    onShareAppMessage: function() {},
    getMoreData: function() {
        var t = this, e = this, i = a.getNetAddresss("plugin.article.api.article.audioArticle");
        i += "&display_order=" + this.data.display_order, i += "&page=" + this.data.page, 
        e.setData({
            isLoadMore: !1,
            page: this.data.page
        }), a._getNetWork({
            url: i,
            success: function(a) {
                var i = a.data;
                1 == i.result ? (e.setData({
                    isLoadMore: !0,
                    total_page: i.data.last_page,
                    total: i.data.total
                }), e.data.total_page || e.setData({
                    total_page: 0
                }), e.data.total || e.setData({
                    total: 0
                }), e.setData({
                    voiceList: t.data.voiceList.concat(i.data.data)
                })) : wx.showToast({
                    title: i.msg,
                    icon: "none",
                    duration: 2e3
                });
            },
            fail: function(a) {
                console.log(a);
            }
        });
    },
    getData: function() {
        var t = this, e = a.getNetAddresss("plugin.article.api.article.audioArticle");
        e += "&display_order=" + this.data.display_order, t.setData({
            isLoadMore: !1,
            page: 1
        }), a._getNetWork({
            url: e,
            success: function(a) {
                var e = a.data;
                1 == e.result ? (t.setData({
                    isLoadMore: !0,
                    total_page: e.data.last_page,
                    total: e.data.total
                }), t.data.total_page || t.setData({
                    total_page: 0
                }), t.data.total || t.setData({
                    total: 0
                }), t.setData({
                    voiceList: e.data.data
                })) : wx.showToast({
                    title: e.msg,
                    icon: "none",
                    duration: 2e3
                });
            },
            fail: function(a) {
                console.log(a);
            }
        });
    },
    changeAsc: function() {
        this.setData({
            isAsc: !this.data.isAsc
        }), this.data.isAsc ? this.setData({
            display_order: ""
        }) : this.setData({
            display_order: 1
        }), this.getData();
    },
    toVoice: function(a) {
        var t = a.currentTarget.dataset.item;
        t.has_one_article_pay ? t.has_one_record ? wx.navigateTo({
            url: "/packageA/member/course/VoiceDetail/VoiceDetail?article_id=" + t.id
        }) : wx.navigateTo({
            url: "/packageD/article/articleList/articleList?article_id=" + t.id
        }) : wx.navigateTo({
            url: "/packageA/member/course/VoiceDetail/VoiceDetail?article_id=" + t.id
        });
    }
});